package com.second.mapper;


import com.second.model.pojo.FCoupon;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;


@Repository //持久层组件标识
public interface IFCouponMapper extends JpaRepository<FCoupon,Integer> {

    List<FCoupon> findAllById(Iterable<Integer> Id);

    List<FCoupon> findAll();

    Optional<FCoupon> findById(Integer Id);

    List<FCoupon> findAllByStatusAndType(Integer status,Integer type);

    @Modifying
    @Transactional
    @Query("update FCoupon set status=1 where id = ?1 ")
    int updateStatus(Integer couponId);

}
